<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
         let obj = null;
        (function () {
          let a = '';
          obj = Object.create({}, {
                name: {
                    value: "值",
                    writable: true,
                    configurable: true,
                    enumerable: true
                },
                age: {
                    get: function () {
                        console.log("调用了get");

                        // 添加业务逻辑

                        // console.log(this);
                        // return this.a;
                        return a + '岁了';
                    },
                    set: function (val) {
                        console.log(val);
                        console.log("调用了set");
                        // console.log(this);
                        // this.a = val;
                        a = this.name + val;
                    },
                    configurable:true,
                    enumerable: true
                }
            })
        })()

        console.log(obj);

        // 相当于调用 age下的get方法
        // console.log(obj.age);

        // 调用了age下的set方法
        obj.age = 88;

        delete obj.age;

        console.log(obj);

    </script>
</body>

</html>